﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

// -----------------------------------------------------------------------
// <copyright file="$safeitemrootname$.cs" company="$registeredorganization$">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------
namespace NewGame
{
    public class My3DModel : MyModel
    {
        public My3DModel(ContentManager content, string strName, float scale, Vector3 pos, float rotationY)
        {
            // TODO: Complete member initialization
            
            _model = content.Load<Model>(strName);
            _transformMatrix = Matrix.Identity;
            Scale= scale;
            Position = pos;
            RotationY = rotationY;
            
        }

        public override void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, Effect effect, MyCamera camera)
        {
            //_transformMatrix = _rotation * Matrix.CreateScale(_scale) * Matrix.CreateTranslation(_position);
            foreach (ModelMesh mesh in _model.Meshes)
            {
                foreach (BasicEffect eff in mesh.Effects)
                {
                    eff.EnableDefaultLighting();
                    eff.View = camera.View;
                    eff.Projection = camera.Projection;

                    eff.FogEnabled = true;
                    eff.FogStart = 50.0f;
                    eff.FogEnd = 200.0f;
                    eff.FogColor = new Vector3(0.9f, 0.9f, 0.9f);
                   // eff.Alpha = 0.2f;
                    eff.SpecularColor = new Vector3(0.25f);
                    eff.SpecularPower = 16;
                    eff.World = Matrix.CreateRotationX(-MathHelper.PiOver2) * _transformMatrix;
                }
                mesh.Draw();
            }
        }
         public void DrawWithFog(GameTime gameTime, GraphicsDevice graphicsDevice, Effect effect, MyCamera camera,float startFog,float endFog )
        {
            
            foreach (ModelMesh mesh in _model.Meshes)
            {
                foreach (BasicEffect eff in mesh.Effects)
                {
                    eff.EnableDefaultLighting();
                    eff.View = camera.View;
                    eff.Projection = camera.Projection;

                    eff.FogEnabled = true;
                    eff.FogStart = startFog;
                    eff.FogEnd = endFog;
                    eff.FogColor = new Vector3(0.9f, 0.9f, 0.9f);

                     eff.SpecularColor = new Vector3(0.25f);
                    eff.SpecularPower = 16;
                    eff.World = Matrix.CreateRotationX(-MathHelper.PiOver2)*_transformMatrix;
                }
                mesh.Draw();
            }
            
        }


    }
}
